<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<html>
	<head>
		<script language="javascript" src="<%=contextPath%>/js/func.js"type=""></script>
		<script type="text/javascript" src="<%=contextPath%>/js/validator.js"></script> 
		<script>
			Ext.onReady(function(){
				var tb = new Ext.Toolbar({
			   		renderTo: document.all.tbar,
			    	items: [['->'],
				        {
				            text: '授权',
							cls:'x-btn-text-icon',
            				icon:'<%=contextPath%>/images/user_add.png',
				            handler:function() {
				            	deleteIt('1');
				            },
				            hidden:<%=session.getAttribute("btn_role_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>
				        },'-',
				        {
				            text: '取消授权',
				            cls:'x-btn-text-icon',
				            icon:"<%=contextPath%>/images/user_delete.gif",
				            handler:function() {
				            	deleteIt('0');
				            },
				            hidden:<%=session.getAttribute("btn_unrole_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>
				        },'-',
				        {
				            text: '关闭',
				            icon:"<%=contextPath%>/images/banjie.png",
				            handler:function() {
				            	self.close();
				            }
				        }
			    	]
			    });
			});
		</script>
	<base target="_self" />
	<body>
		<div id ='tbar'></div>
		<form id="frmM" name="frmM" method="POST" action="<%=contextPath%>/queryUser.do">
			<input type="hidden" value="${userId}" name="userId">
			<table width="100%" id="listtab">
				<tr>
					<th width="25">
						<input name="chkAll" type="checkbox" id="chkAll"
							onclick="javascript:checkAll(this.form, 'id');" value="checkbox">
					</th>
					<th width="80" nowrap>是否赋角色</th>
					<th width="200">角色名称</th>
					<th >角色描述</th>
				</tr>
				
				<c:forEach items="${list}" var="role" >
					<tr>
						<td width="25">
							<input type="checkbox" name="id" value="${role['id']}" />
						<br></td>
						<td width="80" nowrap>
							<c:if test="${role['rcount']==0}">
								<font color='red'>否</font>
							</c:if>
							<c:if test="${role['rcount']>0}">
								<font color='green'>是</font>
							</c:if>
						<br></td>
						<td width="200">
							${role['name']}
						<br></td>

						<td class="lf">${role['notes']}</td>
					</tr>
				</c:forEach>

				<c:if test="${list == null || fn:length(list) == 0 }">
					<tr>
						<td colspan="6" style="text-align: center">
							无相关记录
						</td>
					</tr>
				</c:if>
			</table>
			
			<table width="100%" id="tablestyle2">

				<tr>
					<td>
						<hr />
					</td>
				</tr>
			</table>
			
		</form>
	</body>
</html>
<script language="javascript">

			// 删除
			function deleteIt(flag)
			{
				
				var m = "授权";
				
				if (flag == "0") {
					m = "取消授权";
				}	
				if(!isChecked("id")) {
		 			alert("请选择要" + m + "的角色。");
		 			return false;
		 		}
		 		
		    	if(confirm("确定要" + m + "选中的角色吗？")) {
		        	document.frmM.action = "<%=contextPath%>/user!saveUserRole.do?flagSQ=" + flag;// + "&ouid=" + window.dialogArguments.document.getElementById("searchBean.con1").value;
					document.frmM.submit();
		    	}
			}
			
		</script>